package com.lagou.demo.controller;

import com.lagou.demo.service.IDemoService;
import com.lagou.edu.mvcframework.annotations.LagouAutowired;
import com.lagou.edu.mvcframework.annotations.LagouController;
import com.lagou.edu.mvcframework.annotations.LagouRequestMapping;
import com.lagou.edu.mvcframework.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@LagouController
@LagouRequestMapping("/test1")
@Security({"zhangsan", "lisi"}) // 标记在Controller上，表示该Controller中所有方法都做权限控制
public class Test1Controller {

    @LagouAutowired
    private IDemoService demoService;

    @LagouRequestMapping("/handle1")
    public String handle1(HttpServletRequest request, HttpServletResponse response, String username) {
        return demoService.get(username);
    }

    @Security({"zhangsan"})
    @LagouRequestMapping("/handle2")
    public String handle2(HttpServletRequest request, HttpServletResponse response, String username) {
        return demoService.get(username);
    }

    @Security({"lisi"})
    @LagouRequestMapping("/handle3")
    public String handle3(HttpServletRequest request, HttpServletResponse response, String username) {
        return demoService.get(username);
    }

    @LagouRequestMapping("/handle4")
    @Security({"wangwu"})
    public String handle5(HttpServletRequest request, HttpServletResponse response, String username) {
        return demoService.get(username);
    }

    @LagouRequestMapping("/handle5")
    @Security
    public String test6(HttpServletRequest request, HttpServletResponse response, String username) {
        return demoService.get(username);
    }
}
